/*
 * Copyright (c) 2017 Open. All rights reserved.
 * @(#) SignInForm.java 2017-07-08 22:08
 */

package com.laf.LAF.domain.user;

import com.google.common.base.MoreObjects;
import lombok.Data;

import javax.validation.constraints.NotNull;

import static org.springframework.util.StringUtils.hasText;

/**
 * @author WuGang
 * @since 1.0
 */
@Data
public class SignInForm implements UserForm {

    private static final long serialVersionUID = 3169892303146515191L;

    public static final String PROP_MOBILE = "mobile";
    public static final String PROP_PASSWORD = "password";
    public static final String PROP_SOURCE = "source";
    public static final String PROP_OPEN_ID = "openId";
    // public static final String PROP_UNION_ID = "unionId";

    private String mobile;
    private String password;
    /* @NotNull(message = "用户来源不能为空")
     private UserSource source;*/
    private String openId;
    // private String unionId;
    private String imei;
    private String os;

    @Override
    public String validate() {
       /* if (UserSource.NORMAL.equals(source)) {
            if (!hasText(mobile) || !hasText(password)) {
                return "请输入手机号和密码";
            }
        } else {
            if (!hasText(openId)) {
                return "openId不能为空";
            }
        }*/
        return null;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("mobile", mobile)
                .add("password", password)
                // .add("source", source)
                .add("openId", openId)
//                .add("unionId", unionId)
                .toString();
    }
}
